//
//  NSArray+LGF.m
//  LGFDemo
//
//  Created by 樱桃李子 on 2018/8/14.
//  Copyright © 2018年 lee. All rights reserved.
//

#import "NSArray+LGF.h"
#import <objc/runtime.h>


@implementation NSArray (LGF)

+(void)load
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        method_exchangeImplementations(class_getInstanceMethod(NSClassFromString(@"__NSSArrayI"), NSSelectorFromString(@"objectAtIndex:")), class_getInstanceMethod(NSClassFromString(@"NSSArray"), NSSelectorFromString(@"LGF_setObject:")));
    });
}

-(id)LGF_setObject:(NSInteger)index
{
    //判断数组是否越界
    if (index >= [self count]) {
        return nil;
    }
    return [self LGF_setObject:index];
}



@end
